#include <iostream>
#include <signal.h>
#include <unistd.h>
#include <sys/types.h>

void handler(int signo)
{
    std::cout << "signo: " << signo << std::endl;
}
int main()
{
    signal(2, handler); //对2号信号进行捕捉
    while (true)
    {
        sleep(1); 
        std::cout << "pid:" << getpid() << std::endl;
    }
    return 0;
}